package com.yanq.liancar.activity;

import android.os.Bundle;
import android.widget.TextView;

import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.vondear.rxtool.RxSPTool;
import com.vondear.rxtool.view.RxToast;
import com.yanq.liancar.R;
import com.yanq.liancar.activity.base.BaseToolbarActivity;
import com.yanq.liancar.util.Utils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SmallBBindingWeChatActivity extends BaseToolbarActivity {

    @BindView(R.id.SmallBBindingWeChat_btn)
    TextView SmallBBindingWeChatBtn;
    private static  final  String APP_ID="wxd2e19fc6b6f17ec0";
    private IWXAPI api;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_small_bbinding_we_chat);
        Utils.setStatusBar(this, true, false);
        ButterKnife.bind(this);
        mTvTitle.setText("账号绑定");
    }

    @OnClick(R.id.SmallBBindingWeChat_btn)
    public void onViewClicked() {
        api= WXAPIFactory.createWXAPI(this,APP_ID,true);
        api.registerApp(APP_ID);
        // 判断是否安装了微信客户端
        if (!api.isWXAppInstalled()) {
            RxToast.error("您还未安装微信客户端！");
        }else {
            RxSPTool.putString(this, "WeChatType","bind");
            SendAuth.Req req = new SendAuth.Req();
            req.scope = "snsapi_userinfo";
            req.state = "wechat_sdk_demo";
            api.sendReq(req);
            finish();
        }
    }
}
